﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace XboxOneDriverApp
{
    public static class UserData
    {
        public static readonly float version = 1.0f;

        public static List<string> gameFolders;

        public static void Write(Stream stream)
        {
            BinaryWriter writer = new BinaryWriter(stream);
            writer.Write(version);

            writer.Write(gameFolders.Count);
            for (int i = 0; i < gameFolders.Count; i++)
            {
                writer.Write(gameFolders[i]);
            }
        }

        public static void Read(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream);
            float v = reader.ReadSingle();
            if (v > version)
            {
                throw new Exception();
            }

            int count = reader.ReadInt32();
            gameFolders = new List<string>(count);

            for (int i = 0; i < count; i++)
            {
                string path = reader.ReadString();
                gameFolders.Add(path);
            }
        }
    }
}
